repo: Introspect _sign_commit() and _verify_commit()
authorColin Walters <walters@verbum.org>
Mon, 23 Dec 2013 16:40:57 +0000 (11:40 -0500)
committerColin Walters <walters@verbum.org>
Mon, 23 Dec 2013 16:40:57 +0000 (11:40 -0500)
We can't use #ifdef in the headers, since then g-ir-scanner won't pick
up the functions (unless we included config.h).  Let's instead always
have the symbols, but just set an error if we were built without
support for it, just like how pull works.

src/libostree/ostree-repo.c
src/libostree/ostree-repo.h

index 20b4d0988d485e0a7244c2e775ab22285fad5601..372becd8fce33132fab9824d050dbf52f92280fa 100644 (file)
@@ -1478,7 +1478,6 @@ ostree_repo_pull (OstreeRepo               *self,
 }
 #endif
 
-#ifdef HAVE_GPGME
 gboolean
 ostree_repo_sign_commit (OstreeRepo     *self,
                          const gchar    *commit_checksum,
@@ -1487,6 +1486,7 @@ ostree_repo_sign_commit (OstreeRepo     *self,
                          GCancellable   *cancellable,
                          GError        **error)
 {
+#ifdef HAVE_GPGME
   gboolean ret = FALSE;
   gs_unref_object GFile *commit_path = NULL;
   gs_unref_variant GVariant *metadata = NULL;
@@ -1648,6 +1648,11 @@ out:
   if (signature_file)
     g_mapped_file_unref (signature_file);
   return ret;
+#else
+  g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+               "This version of ostree was compiled without GPG support");
+  return FALSE;
+#endif
 }
 
 /**
@@ -1670,6 +1675,7 @@ ostree_repo_verify_commit (OstreeRepo   *self,
                            GCancellable *cancellable,
                            GError      **error)
 {
+#ifdef HAVE_GPGME
   gboolean ret = FALSE;
   gs_unref_object OstreeGpgVerifier *verifier = NULL;
   gs_unref_variant GVariant *commit_variant = NULL;
@@ -1778,6 +1784,9 @@ out:
   if (commit_tmp_path)
     (void) gs_file_unlink (commit_tmp_path, NULL, NULL);
   return ret;
-}
-
+#else
+  g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+               "This version of ostree was compiled without GPG support");
+  return FALSE;
 #endif
+}
index 6a97f6b83195c97d6a7ffb17f3633cce38ec2bff..2186389d831eab784ea27d09c28ff246eff0e61b 100644 (file)
@@ -466,7 +466,6 @@ gboolean ostree_repo_pull (OstreeRepo             *self,
                            GCancellable           *cancellable,
                            GError                **error);
 
-#ifdef HAVE_GPGME
 gboolean ostree_repo_sign_commit (OstreeRepo     *self,
                                   const gchar    *commit_checksum,
                                   const gchar    *key_id,
@@ -480,7 +479,6 @@ gboolean ostree_repo_verify_commit (OstreeRepo   *self,
                                     GFile        *extra_keyring,
                                     GCancellable *cancellable,
                                     GError      **error);
-#endif
 
 G_END_DECLS